from concurrent.futures import ProcessPoolExecutor
from concurrent.futures import ThreadPoolExecutor
import math
import time

PRIMES = [112272535095293] * 50


def is_prime(n):
    if n < 2:
        return False
    if n == 2:
        return True
    if n % 2 == 0:
        return False
    sqrt_n = int(math.floor(math.sqrt(n)))
    for i in range(3, sqrt_n + 1, 2):
        if n % i == 0:
            return False
    return True


def multi_process():
    with ProcessPoolExecutor() as process_pool:
        process_pool.map(is_prime, PRIMES)


def multi_thread():
    with ThreadPoolExecutor() as thread_pool:
        thread_pool.map(is_prime, PRIMES)


def single_thread():
    for num in PRIMES:
        is_prime(num)


if __name__ == '__main__':
   start_time = time.time()
   single_thread()
   end_time = time.time()
   print('single_thread during time: %s' % (end_time - start_time))

   start_time = time.time()
   multi_thread()
   end_time = time.time()
   print('single_thread during time: %s'% (end_time - start_time))

   start_time = time.time()
   multi_process()
   end_time = time.time()
   print('single_thread during time: %s' % (end_time - start_time))
